package com.llkj.qingnianguoxue.adapter;

import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.bean.CourseEvaluateBean;
import com.llkj.qingnianguoxue.util.DateUtils;
import com.llkj.qingnianguoxue.util.ImageLoadingUtil;

import java.util.List;

/**
 * 推荐曲库适配器
 */
public class RecommendMusicAdapter extends BaseQuickAdapter<CourseEvaluateBean, BaseViewHolder> {

    private int mType;

    public RecommendMusicAdapter(int layoutResId, List<CourseEvaluateBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, CourseEvaluateBean item) {
        ImageView ivHead = baseViewHolder.getView(R.id.iv_head);
        ImageLoadingUtil.loadImgGlideRound(ivHead,item.getSing_img());
        baseViewHolder.setText(R.id.tv_title, item.getName());
        baseViewHolder.setText(R.id.tv_time, item.getLength_time());
        baseViewHolder.setText(R.id.tv_count,item.getPlay_num()+"人唱过");

        TextView btnSing = baseViewHolder.getView(R.id.btnSing);

        ImageView ivPraise = baseViewHolder.getView(R.id.ivPraise);
        if("1".equals(item.getIs_like())){
            ivPraise.setSelected(true);
        }else{
            ivPraise.setSelected(false);
        }

        if(mType==1){
            ivPraise.setVisibility(View.GONE);
        }

        baseViewHolder.addOnClickListener(R.id.btnSing);
        baseViewHolder.addOnClickListener(R.id.ivPraise);
    }

    public void setType(int type){
        mType = type;
    }
}
